package cn.iot.sys.service.impl;

import cn.iot.common.dto.ResultMsg;
import cn.iot.sys.dao.SysGradeDao;
import cn.iot.sys.entity.SysGrade;
import cn.iot.sys.service.SysGradeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysGradeServiceImpl implements SysGradeService {
    @Resource
    private SysGradeDao sysGradeDao;
    public Logger logger = LoggerFactory.getLogger(getClass());
    @Override
    public ResultMsg getSysGrade() {
        logger.info("SysClassServiceImpl getSysGrade start ...");
        List<SysGrade> sysGrade = sysGradeDao.getSysGrade();
        ResultMsg msg = new ResultMsg(200,"成功",sysGrade);
        return msg;
    }

    @Override
    public ResultMsg getGradeByName(String gradeName) {
        logger.info("SysClassServiceImpl getGradeByName gradeName{}",gradeName);
        SysGrade sysGrade = sysGradeDao.getGradeByName(gradeName);
        ResultMsg msg;
        if (sysGrade != null){
            msg = new ResultMsg(200,"成功",sysGrade);
            return msg;
        }
        msg = new ResultMsg(500,"失败",null);
        return msg;
    }
}
